// 判断用户名
    async function judgeUser(user){
        var userReg = /^[a-zA-Z$_][\w$]{5,11}$/;
        if (userReg.test(user) ) {
            var result = await isExistUser({user})
            if(result.status) {
                return result;
            } else {
                throw result;
            }
        } else {
            throw({
                status:false,
                msg:"用户名由数字,字母,下划线,$组成，6~12位,不能以数字开头"
            })
        }
    }
// 判断手机号
    async function judgePhone(phone){
        var phoneReg = /^1[3456789][\d]{9}$/;
        if (phoneReg.test(phone) ) {
            var result = await isExistPhone({phone});
            if(result.status) {
                return result;
            } else {
                throw result;
            }
        } else {
            throw({
                status:false,
                msg:"请输入正确的手机号",
            })
        }
    }
// 判断邮箱
    async function judgeEmail(email){
        var emailReg = /^\w{6,18}@\w+\.com$/;
        if (emailReg.test(email) ) {
            var result = await isExistEmail({email})
                if(result.status) {
                    return (result);
                } else {
                    throw(result);
                };
        } else {
            throw({
                status:false,
                msg:"请输入正确的邮箱",
            })
        }
    }
// 判断密码
    async function judgePwd(pwd){
        var pwdReg = /^[\w$]{6,12}$/;
        if (pwdReg.test(pwd) ) {
            //  判断密码强度
            var numFlag = false;     //假设不存在数字
            var bigFlag = false;     //假设不存在大写字母
            var smallFlag = false;   //假设不存在小写字母
            var speFlag = false;     //假设不存在特殊字符
            
            var numReg = /[0-9]/;                 
            var bigReg = /[A-Z]/;     
            var smallReg = /[a-z]/;   
            var speReg = /[_$]/;

            if (numReg.test(pwd))   numFlag = true;     //验证存在数字
            if (bigReg.test(pwd))  bigFlag = true;     //验证存在大写字母
            if (smallReg.test(pwd))   smallFlag = true;   //验证存小写字母
            if (speReg.test(pwd))    speFlag = true;      //验证存在特殊字符  

            var sum = numFlag + bigFlag + smallFlag + speFlag; 
            switch(sum) {
                case 1: 
                    msg = "密码强度弱";
                    break;
                case 2: 
                    msg = "密码强度中";
                    break;
                case 3: 
                    msg = "密码强度强";
                    break;
                case 4: 
                    msg = "密码强度超强";
                    break;    
            }
            return ({
                msg,
                status:true,
            });
        } else {
            throw ({
                msg:"密码6至12位的数字,大小写字母,_,$ 组成",
                status:false,
            });
        }
    }
// 判断验证码
    async function judgeCode(code,_rand) {
        var codeReg = new RegExp(_rand,"i");
        if (codeReg.test(code) ) {
            return {
                msg:"√",
            };
        } else {
            throw {
                msg:"×"
            };
            
        }
    }